/**
 * @Description 评价问题到
 * @author 20155872 游宇
 * @create 2018-05-10 10:54
 **/

package com.campus_information_portal.dao;

import com.campus_information_portal.entity.Question;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 20155872 游宇
 * @className QuestionDao
 * @Description 评价问题dao
 * @create 2018-05-10 10:54
 **/
public interface QuestionDao {
    /**
     * @Description: 发布评价问题（往Question表中插入一条记录）
     * @author: 20155872 游宇
     * @methodName: addQuestion
     * @Param Question question
     * @returnType: boolean
     * @createTime: 2018-05-10 10:55
     * @errorandsolusion: 对应实体类的属性，如果时传一个对象，那么就不用加 @Param
     **/
    @Insert("insert into question(term_id,question_one,question_two,question_three," +
            "question_four,question_five,question_six,question_seven,question_eight,question_nine,question_ten)" +
            "values(#{termId},#{questionOne},#{questionTwo},#{questionThree}," +
            "#{questionFour},#{questionFive},#{questionSix},#{questionSeven},#{questionEight}," +
            "#{questionNine},#{questionTen})")
    boolean addQuestion(Question question);

    /**
     * @Description: 根据questionid来获取一条记录
     * @author: 20155872 游宇
     * @methodName: getQuestion
     * @param: int questionId
     * @returnType: Question
     * @createTime:
     **/
    @Select("select * from question where question_id=#{questionId}")
    Question getQuestion(@Param("questionId") int questionId);

    /**
     * @Description: 更新问题表记录
     * @author: 20155872 游宇
     * @methodName: updateQuestion
     * @param: Question question
     * @returnType: boolean
     * @createTime: 2018-05-10 10:55
     **/
    @Update("update question set question_one=#{questionOne},question_two=#{questionTwo}," +
            "question_three=#{questionThree},question_four=#{questionFour}," +
            "question_five=#{questionFive},question_six=#{questionSix}," +
            "question_seven=#{questionSeven},question_eight=#{questionEight}," +
            "question_nine=#{questionNine},question_ten=#{questionTen} where question_id=#{questionId}")
    boolean updateQuestion(Question question);

    /**
     * @Description: 查询所有的评价问题
     * @author: 20155872 游宇
     * @methodName: findAllQuestion
     * @param: null
     * @returnType: List<Question>
     * @createTime: 2018-05-10 10:56
     **/
    @Select("select * from Question")
    List<Question> findAllQuestion();

    /**
     * @Description: 根据学期id查询某一个学期的评价问题
     * @author: 20155872 游宇
     * @methodName: findQuestionByTermid
     * @param: int term_id
     * @returnType: List<Question>
     * @createTime: 2018-05-10 10:56
     **/
    @Select("select * from Question where term_id=#{term_id}")
    Question findQuestionByTermid(@Param("term_id") int term_id);

    /**
     * @Description: 清空评价问题表中的所有记录
     * @author: 20155872 游宇
     * @methodName: deleteAllQuestion
     * @param: null
     * @returnType: boolean
     * @createTime: 2018-05-10 10:56
     **/
    @Delete("delete from Question")
    boolean deleteAllQuestion();

    /**
     * @Description: 根据评价问题记录id删除评价问题表中的记录
     * @author: 20155872 游宇
     * @methodName: deleteQuestionByterm_id
     * @param: null
     * @returnType: boolean
     * @createTime: 2018-05-10 10:56
     **/
    @Delete("delete from Question where question_id=#{questionId}")
    boolean deleteQuestionByQuestion_id(@Param("questionId") int question_id);

}
